function isIE6(){
	var isIE = (document.all) ? true : false;
    var isIE6 = isIE && ([/MSIE (\d+)\.0/i.exec(navigator.userAgent)][0][1] == 6);
    return isIE6;
}

$.ajaxSetup({
	contentType : "application/x-www-form-urlencoded;charset=utf-8",
	complete : function(XMLHttpRequest, textStatus) {
		var sessionstatus = XMLHttpRequest.getResponseHeader("sessionstatus"); // 通过XMLHttpRequest取得响应头，sessionstatus，
		if (sessionstatus == "timeout") {
			// 如果超时就处理 ，指定要跳转的页面
			window.top.location.href="/login";
		}
		var permissionStatus = XMLHttpRequest.getResponseHeader("permissionStatus");
		if(permissionStatus == "noPermission"){
			error("你没有权限!");
		}
	},
	statusCode: {404: function() {
						error('404 请求地址不存在！');
	 				  },
 				 500: function() {
						error('系统错误！');
	 			       }
				  }
				 
});



/**
 * 消息提示
 */
(function($) {
	$.shen_message = function(message, type) {
		$.scojs_message(message, type);
		$("#" + $.scojs_message.options.id).mouseover(function() {
			this.style.cursor = "pointer";
		}).click(function() {
			$(this).hide();
		});
	};
	$.extend($.shen_message, $.scojs_message);
})(jQuery);


function info(msg){
	$.shen_message(msg,$.shen_message.TYPE_OK);
}

function error(msg){
	$.shen_message(msg,$.shen_message.TYPE_ERROR);
}

var lockHtml='<div style="width:100%;height:100%;position:absolute;z-index:9999999;top:45%;left:45%"><img src="/img/loading.gif"/></div>';

/**
 * 锁屏 解锁
 */
(function($) {
	$.shen_screenLock = function(id,html) {
		var lockDiv = window.top.document.createElement("div");
		lockDiv.id=id;
	    lockDiv.className = "lock";
	    if(html){
	    	$(lockDiv).append(html);
	    }
	    if(isIE6()){
	    	lockDiv.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
	    	lockDiv.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
	    	$(window.top).resize(function(){
	    		$(".lock").css("width",Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px");
	    		$(".lock").css("height",Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px");
	    	});
	    }
	    window.top.document.body.appendChild(lockDiv);
	};

	$.shen_screenUnlock = function(id){
		$(window.top.document).find("#"+id).remove();
	};
})(jQuery);

/**
 * 时间转换 转换为long
 */
(function($){
	/**
	 * date 日期 形如 1945-08-15 12:23:45
	 * splitSingn 年月日的分隔符 如上为 - 
	 */
	$.shen_strDateToTime = function(date,splitSingn){
		 var temp0 = date.split(" ");
		 if(splitSingn!="-"&&splitSingn!="/"){
			 var reg = new RegExp(splitSingn,"g");
			 temp0[0] = temp0[0].replace(reg,"-");
		 }
		 var temp2 = temp0[0].split(splitSingn);
		 date = temp2[1]+splitSingn+temp2[2]+splitSingn+temp2[0]+" "+temp0[1]; 
		 return Date.parse(date);  
	};
})(jQuery);


Date.prototype.toString = function() {
  return this.getFullYear()
        + "-" + (this.getMonth()>8?(this.getMonth()+1):"0"+(this.getMonth()+1))
        + "-" + (this.getDate()>9?this.getDate():"0"+this.getDate())
        + " " + (this.getHours()>9?this.getHours():"0"+this.getHours())
        + ":" + (this.getMinutes()>9?this.getMinutes():"0"+this.getMinutes())
        + ":" + (this.getSeconds()>9?this.getSeconds():"0"+this.getSeconds());
}

function notFixedLeftMenu(){
	$(".leftFixMenu").css({"position":"static","margin":"0 0 60px 0px"});
}